package com.yenlien.traceyun.breed.dao;

import com.yenlien.traceyun.breed.entity.BreedCropDetail;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by LiuSha on 2020/9/23.
 */
public interface BreedCropDetailDao extends BaseJpaDao<BreedCropDetail> {
    BreedCropDetail findById(String id);

    List<BreedCropDetail> findByBreedCropId(String breedCropId);

    /**
     * 根据产出物id删除
     *
     * @param breedCropId
     */
    public void deleteByBreedCropId(String breedCropId);

    @Query(value = "SELECT COUNT(tbcd.type) FROM `t_breed_crop` tbc JOIN t_breed_crop_detail tbcd ON tbc.id = tbcd.breed_crop_id WHERE tbc.company_id = ?1 AND tbcd.type = 'RFID'", nativeQuery = true)
    Integer countByCompId(String companyId);
}
